package com.huixuebao.settle.controller;

import com.huixuebao.common.bean.ApiResult;
import com.huixuebao.settle.dto.CategoryDTO;
import com.huixuebao.settle.service.CategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController()
@RequestMapping("/category")
public class CategoryController {

    @Autowired
    CategoryService categoryService;

    @GetMapping("/categoryTree")
    public ApiResult buildAreaTree() {
        return categoryService.categoryTree();
    }

    @GetMapping("/listAllCategoryByPid")
    public ApiResult<List<CategoryDTO>> listAllCategoryByPid(@RequestParam("pid") String pid) {
        return categoryService.listAllCategoryByPid(pid);
    }

}
